home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Visual Database / Visual Foxpro 6.0 (Ent. Edition) / Vf6ent Extractor.EXE / TOOLS / XSOURCE / XSOURCE.ZIP / vfpsource / wizards / Wzgraph / graphwiz.prg < prev    next >
Encoding:
Text File  |  1998-05-01  |  7.0 KB  |  233 lines

  1. #DEFINE E_NOAUTGRAPH_LOC    "Failed to create AutoGraph Object."
  2.  
  3. * _GENGRAPH assumes that the table to chart is already selected. The 
  4. * category axis is based on the first field. The other fields (those
  5. * which are numeric) are used as data fields.
  6.  
  7. ****************Sample/Testing****************
  8. #IFDEF devmode
  9. SET PROCEDURE TO wzengine ADDITIVE
  10. SET CLASS TO graph
  11. x=CREATE('GraphEngine')
  12. x.nWizAction = 1
  13. x.lSeriesByRow = .F.            &&Chart SubType
  14. *x.lUseAutoFormat = .T.
  15. *x.cChartAutoGallery = 4
  16. *x.cChartAutoFormat = 8
  17. x.nChartType =       5                &&Chart Type
  18. x.nChartSubType = 1                &&Chart SubType
  19. x.cCategoryField = 'country'
  20. USE offices
  21. x.makeoutput
  22. #ENDIF
  23. ***************************************
  24.  
  25. DEFINE CLASS GraphEngine AS WizEngineAll
  26.  
  27.     oG = .NULL.                    && graph automation object reference
  28.     oGraphRef = ""                &&graph reference
  29.     graphpreview = ""            &&preview reference
  30.     iHelpContextID = 1895825413    &&help id
  31.     nSaveLocaleId = 1033        &&saved locale id
  32.     nGraphVersion = 5            &&graph version
  33.     
  34.     nWizAction = 1                && 1 = save to form, 2 = save to graph, 3 = save as query
  35.     cWizClass = "ole"            &&wizard class    (e.g., report)
  36.     cWizName  = "graphwizard"    &&wizard name or class (e.g., Group/Total report)
  37.     cDefNewField = "olegraph"    &&default field name in new table
  38.     cOutFile = ""
  39.     cWizAlias = ""
  40.     lHadPreview = .F.            &&had a preview already and may have changed data in MS Graph
  41.     cLastDataRow = ""            &&last contents added to Series by Row
  42.     cLastDataCol = ""            &&last contents added to Series by Col
  43.     cOutGenField = ""            &&output field name
  44.  
  45.     lAddLegend = .T.            &&Add Legend
  46.     lAddTitle  = .T.            &&Add Title
  47.     lSeriesByRow = .T.            &&Series by Row (.T.), by Column (.F.)
  48.     lUseAutoFormat = .F.        &&Use autoformat
  49.     cTitle = ""                    &&Title
  50.     nCatCapital = 0                &&Category capitalization (3-proper,1-lower,2-upper)
  51.     lAutoGraph = .F.            &&Autograph
  52.     lShowNulls = .T.            &&Include rows with null values
  53.     lAddedData = .F.            && has data been added to the graph?
  54.     
  55.     nChartType = 1                &&Chart Type
  56.     nChartSubType = 1            &&Chart SubType
  57.     cChartAutoGallery = 1        &&Chart autoformat gallery
  58.     cChartAutoFormat = 1         &&Chart autoformat format
  59.     lReplaceDBF = .T.            &&Replace Graph DBF vs Append
  60.     cOpenAlias = ""                &&Alias of output table if already opened
  61.     
  62.     DIMENSION aDataFields[1]
  63.     aDataFields = ""                        && data fields used
  64.     cCategoryField = ""                        && category field used
  65.     
  66.     * Defaults
  67.     cGraphDBF = "wizgraph.dbf"                && DBF containing cGraphField
  68.     cGraphFldRow = "graph_row"                && General field containing setup Graph (series by row)
  69.     cGraphFldCol = "graph_col"                && General field containing setup Graph (series by col)
  70.     cOleServer    = "msgraph.application.5"
  71.     cGraphField = "graph_row"                && graph_row or graph_col type
  72.     cGraphPrevClass = "GraphPreview"        && Class containing preview form
  73.  
  74.     PROCEDURE AutoGraph
  75.         LPARAMETER p1,p2,p3,p4,p5,p6,p7,p8,p9
  76.         *   parm1 - chart type (number)
  77.         *   parm2 - chart subtype (number)
  78.         *   parm3 - title (if not empty)
  79.         *   parm4 - series by row (.T.), by column (.F.)
  80.         *   parm5 - has legend (.T.)
  81.         *   parm6 - use autoformat (.F.)
  82.         *   parm7 - file name for graph output
  83.         *   parm8 - don't open graph when done
  84.         *    parm9 - show nulls
  85.         
  86.         * Get Chart Type (Also AutoFormat Gallery)
  87.         LOCAL nMaxType,nMaxSubType,lNoModify
  88.         m.nMaxType = IIF(TYPE("m.P6")="L" AND m.P6,15,17)
  89.         m.nMaxSubType = IIF(TYPE("m.P6")="L" AND m.P6,12,4)
  90.         THIS.lAutoGraph = .T.
  91.         m.lNoModify = .F.
  92.  
  93.         * Get Chart Type (Also AutoGallery Format)
  94.         IF PARAMETERS() > 0 AND TYPE("m.p1")="N"
  95.             THIS.nChartType = m.p1
  96.         ENDIF
  97.         
  98.         * Get Chart SubType (Also AutoFormat Format)
  99.         IF PARAMETERS() > 1 AND TYPE("m.p2")="N"
  100.             THIS.nChartSubType = m.p2
  101.         ENDIF
  102.  
  103.         * Get Chart Title
  104.         IF PARAMETERS() > 2 AND TYPE("m.p3")="C" AND !EMPTY(m.p3)
  105.             THIS.cTitle = m.p3
  106.             THIS.lAddTitle = .T.
  107.         ENDIF
  108.  
  109.         * Get Series by row
  110.         IF PARAMETERS() > 3 AND TYPE("m.p4")="L"
  111.             THIS.lSeriesByRow = m.p4
  112.         ENDIF
  113.         
  114.         * Get Chart Legend
  115.         IF PARAMETERS() > 4 AND TYPE("m.p5")="L"
  116.             THIS.lAddLegend = m.p5
  117.         ENDIF
  118.  
  119.         * Get Use AutoFormat
  120.         IF PARAMETERS() > 5 AND TYPE("m.p6")="L"
  121.             THIS.lUseAutoFormat = m.p6
  122.             THIS.cChartAutoGallery = THIS.nChartType   && Chart autoformat gallery
  123.             THIS.cChartAutoFormat = THIS.nChartSubType && Chart autoformat format
  124.         ENDIF
  125.         
  126.         * Get Output file
  127.         IF PARAMETERS() > 6 AND TYPE("m.p7")="C" AND !EMPTY(m.p7)
  128.             DO CASE 
  129.                 CASE THIS.og.ngraphVersion >= 8 AND UPPER(JUSTEXT(m.p7)) == "DBF"
  130.                     THIS.nWizAction = 2
  131.                 CASE THIS.og.ngraphVersion >= 8
  132.                     m.p7 = THIS.ForceExt(m.p7,"SCX")
  133.                     THIS.nWizAction = 1
  134.                 OTHERWISE
  135.                     *- graph 5
  136.                     m.p7 = THIS.ForceExt(m.p7,"DBF")
  137.                     THIS.nWizAction = 2
  138.             ENDCASE
  139.             THIS.cOutFile = m.p7
  140.         ENDIF
  141.         
  142.         * Get whether to open graph in form/dbf when done
  143.         IF TYPE("m.p8")="L" AND m.p8
  144.             m.lNoModify = .T.
  145.         ENDIF
  146.  
  147.         * Get Null display
  148.         IF PARAMETERS() > 8 AND TYPE("m.p9")="L"
  149.             THIS.lShowNulls = m.p9
  150.         ENDIF
  151.     
  152.         THIS.lHadPreview = .F.
  153.  
  154.         THIS.MakeOutPut()
  155.         IF m.lNoModify
  156.             _SHELL = ""
  157.         ENDIF
  158.         
  159.     ENDPROC
  160.  
  161.     *----------------------------------
  162.     PROCEDURE Init2
  163.     *----------------------------------
  164.         *- create the AutoGraph object
  165.         SET CLASS TO AutGraph ADDITIVE
  166.         THIS.oG = CREATEOBJECT("AutoGraph")
  167.         
  168.         IF TYPE("THIS.oG") # 'O'
  169.             THIS.Alert(E_NOAUTGRAPH_LOC)
  170.             RETURN .F.
  171.         ENDIF
  172.         
  173.         THIS.nGraphVersion = THIS.oG.nGraphVersion
  174.  
  175.         RETURN .T.
  176.     ENDPROC
  177.     
  178.     *----------------------------------
  179.     PROCEDURE Destroy
  180.     *----------------------------------
  181.         RELEASE CLASSLIB AutGraph
  182.  
  183.         WizEngineAll::Destroy()        
  184.     ENDPROC
  185.     
  186.     *----------------------------------
  187.     PROCEDURE MakeOutput
  188.     *----------------------------------
  189.  
  190.         LOCAL lRetVal
  191.         
  192.         THIS.oG.cAlias = THIS.cWizAlias
  193.         THIS.oG.cOutFile = THIS.cOutFile
  194.         THIS.oG.nAction = THIS.nWizAction
  195.         THIS.oG.nGraphVersion = THIS.nGraphVersion
  196.         THIS.oG.cTitle = THIS.cTitle
  197.         THIS.oG.nChartAutoGallery = THIS.cChartAutoGallery
  198.         THIS.oG.nChartAutoFormat = THIS.cChartAutoFormat
  199.         THIS.oG.cGraphFldRow = THIS.cGraphFldRow
  200.         THIS.oG.cGraphFldCol = THIS.cGraphFldCol
  201.         THIS.oG.lAddTitle = THIS.lAddTitle
  202.         THIS.oG.nChartType = THIS.nChartType 
  203.         THIS.oG.nChartSubType = THIS.nChartSubType 
  204.         THIS.oG.lSeriesByRow = THIS.lSeriesByRow 
  205.         THIS.oG.lAddLegend = THIS.lAddLegend 
  206.         THIS.oG.lUseAutoFormat = THIS.lUseAutoFormat 
  207.         THIS.oG.lShowNulls = THIS.lShowNulls
  208.         THIS.oG.cGraphDBF = THIS.cGraphDBF
  209.         THIS.oG.cGraphPrevClass = THIS.cGraphPrevClass
  210.         THIS.oG.cGraphField = THIS.cGraphField
  211.         THIS.oG.cOleServer = THIS.cOleServer
  212.         THIS.oG.cDefNewField = THIS.cDefNewField
  213.         THIS.oG.cCategoryField = THIS.cCategoryField
  214.         THIS.oG.lAddedData = THIS.lAddedData
  215.         THIS.oG.lAutoGraph = THIS.lAutoGraph
  216.         DIMENSION THIS.oG.aDataFields[ALEN(THIS.aDataFields,1)]
  217.         ACOPY(THIS.aDataFields, THIS.oG.aDataFields)
  218.  
  219.         lRetVal = THIS.oG.MakeOutput()
  220.  
  221.         IF TYPE("THIS.oG") == 'O' AND !ISNULL(THIS.oG)
  222.             THIS.lAddedData = THIS.oG.lAddedData
  223.         ENDIF
  224.         
  225.         RETURN lRetVal
  226.         
  227.     ENDPROC
  228.  
  229. ENDDEFINE
  230.  
  231. DEFINE CLASS autographform AS FORM
  232.     ADD OBJECT oleboundcontrol1 AS oleboundcontrol
  233. ENDDEFINE